<?php

use Biz\service\activity\Popup as sPopUp;

class ClickAction extends ActionPlugin
{
    const DEFAULT_ERROR_CODE = self::API_CODE_ERROR;

    public function main()
    {
        $popupId = $this->getRequest()->getPost('popup_id', 0);

        if ($popupId) {
            $uid = $this->uid > 0 ? $this->uid : $this->vid;
            $isVisitor = $this->uid ? false : true;
            $result = sPopUp::clickPopUp($uid, $popupId, $isVisitor);
            $msg = $result['msg'];
            if ($msg) {
                $this->setSuccess(null, 1, self::TOSAT_PREFIX . $msg);
            } else {
                $this->setSuccess();
            }
        } else {
            throw new \Exception('参数错误');
        }

    }

}
